package com.dingreading.cloud.web.service.impl;

import com.dingreading.cloud.web.entity.table.ReadingBookTableDef;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.dingreading.cloud.web.entity.ReadingBook;
import com.dingreading.cloud.web.mapper.ReadingBookMapper;
import com.dingreading.cloud.web.service.ReadingBookService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *  服务层实现。
 *
 * @author Administrator
 * @since 2024-11-14
 */
@Service
public class ReadingBookServiceImpl extends BaseServiceImpl<ReadingBookMapper, ReadingBook, ReadingBookTableDef> implements ReadingBookService {

    @Override
    protected ReadingBookTableDef getTable() {
        return ReadingBookTableDef.readingBook;
    }
    @Override
    public List<ReadingBook> listByGrade(Integer grade) {
        QueryWrapper wrapper = QueryWrapper.create()
                .where(table.enabled.eq(1).and(table.grade.eq(grade)))
                .orderBy(table.grade.asc(), table.id.asc());

        return getMapper().selectListByQuery(wrapper);
    }


}
